<?php
session_start();
if(!isset($_SESSION['username'])){
    if ($_SESSION['admin']!="1"){
        header("Location:login.php");
        exit;
    }
}
require ("./core/conn.php");
if ($_POST) {
    if (get_magic_quotes_gpc()) {
        $reply = htmlspecialchars(trim($_POST['reply']));
    } else {
        $reply = addslashes(htmlspecialchars(trim($_POST['reply'])));
    }
    // 修改为空时，将修改时间置为空
    $replytime = $reply ? time() : 'NULL';
    $update_sql = "UPDATE msg SET reply = '$reply', replytime = $replytime WHERE id = $_POST[id]";
    if (mysqli_query($conn, $update_sql)) {
        exit('<script language="javascript">alert("回复成功！");self.location = "index.php";</script>');
    } else {
        exit('回复失败：' . mysqli_error() . '[ <a href="javascript:history.back()">返 回</a> ]');
    }
}
?>